//package org.batatasframework.support.attribute;
//
//import org.batatasframework.support.database.IdentifyTableGenerator;
//import org.batatasframework.support.database.metadatas.DatabaseMetadataResource;
//import org.batatasframework.support.event.SearchableRequest;
//import org.batatasframework.support.searchable.internal.AbstractSearchableHandler;
//
///**
// * <pre>属性表是一个已知结构的数据库表，所以不需要去指定属性表的元数据的表；
// * 这就带来了另一个问题，就是加载的时候，属性表是没有一个默认的表的，所以在生成
// * 查询语句时，需要明确的指定一个表；
// * 所以在对属性表进行查询时，必须重写目标表的生成对象，这一限制如何处理？？</pre>
// * 
// * @author jackson
// *
// */
//@Deprecated
//public class AttributeSearchableHandler extends AbstractSearchableHandler<TableMetadataAttribute>{
//
//	public AttributeSearchableHandler(
//			DatabaseMetadataResource databaseMetadataSources,
//			SearchableRequest searchableConfigurable,
//			TableMetadataAttribute tableMetadata,
//			AutoCloseable needClose) throws Exception {
//		super(databaseMetadataSources, searchableConfigurable, tableMetadata, needClose);
//	}
//	
//	@Override
//	protected IdentifyTableGenerator createDefaultTargetTableGenerator() throws Exception {
//		IdentifyTableGenerator itGenerator = sourceTable.getDefaultTableGenerator();
//		if(null == itGenerator){
//			throw new Exception("必须定义" + IdentifyTableGenerator.class.getSimpleName() + "对象！");
//		}
//		return itGenerator;
//	}
////	
////	@Override
////	public QueryFragmentBuilder newQueryBuilder(TableInstance tableAlias, String fieldName) throws Exception {
////		QueryFragmentBuilder qfb = super.newQueryBuilder(tableAlias, fieldName);
////		FieldMetadata fieldMetadata = qfb.getFieldMetadata();
////		if(fieldMetadata instanceof NeedTemporaryTable){
////			createTemporaryTable();
////			
////			NeedTemporaryTable fieldElementBuilder = (NeedTemporaryTable)fieldMetadata;
////			sourceTableCriterion.tryAddFieldElement(sourceTableCriterion, fieldMetadata, fieldElementBuilder);
////		}
////		
////		return qfb;
////	}
//
////	private String getWhereClause(List<QueryParameter> queryParamenters) throws Exception {
////		if(where.isEmpty()) return "";
////		
////		StringBuilder buf = new StringBuilder( where.size() * 10 );
////		for(QueryFragment qf : where){
////			qf.parse(LogicSymbol.AND, buf, queryParamenters);
////		}
////		return buf.substring(LogicSymbol.AND.getValue().length());
////	}
//	
//	/* -----------------执行查询-------------------- */
////	@Override
////	protected void executeQuery(IdentifyTable tt, ResultBuffer result, String sql, List<QueryParameter> queryParamenters) throws Exception {
////		
////		if(null != temporaryTable){
////			ConnectionAccessor connectionAccessor = tt.getConnectionAccessor();
////			
////			//TEMPORARY TABLE  TODO这里修改
////			try{
////				connectionAccessor.execute("create temporary table " + temporaryTable.getTableName() + " " + sql + ";", queryParamenters);
////			
////				super.executeQuery(tt, result, temporaryTable.getSqlSelect(), temporaryTable.getSqlParamenters());
////				
////			}finally{
////				connectionAccessor.execute(temporaryTable.getSqlDrop());
////			}
////		}else{
////			super.executeQuery(tt, result, sql, queryParamenters);
////		}
////	}
//
////	private String ttDrop;
////	private String ttSql;
////	private List<QueryParameter> ttParamenters = new ArrayList<>();
//	
////	@Override
////	protected void initExecutable(ResultBuffer result, SelectedFieldCollection fieldCollection) throws Exception {
////		if(null != temporaryTable){
////			temporaryTable.finish();
////			
//////			String ttName = temporaryTable.getTableName();
//////			StringBuilder ttSql = new StringBuilder("select * from ").append(ttName).append(" ").append(temporaryTable.getAlias());
//////			String whereClause = temporaryTable.getWhereClause(ttParamenters);
//////			if(!whereClause.isEmpty()){
//////				ttSql.append(" where ").append(whereClause);
//////			}
//////			
//////			this.ttSql = ttSql.toString();
//////			this.ttDrop = "DROP TEMPORARY TABLE IF EXISTS " + ttName + ";";
////		}
////		super.initExecutable(result, fieldCollection);
////	}
//}
